package com.vfashion.model;

import com.vfashion.dao.factory.DAOFactory;
import com.vfashion.domain.Cliente;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author danjoas
 */
public class ClienteModelo {

    public List<HashMap> getLike(String cadena) throws Exception {

        List<Cliente> clientes = DAOFactory.getInst().getClienteDAO().getLike(cadena);
        List<HashMap> lstClientes = new ArrayList<HashMap>();

        for (Cliente c : clientes) {
            System.out.print(c.getIdcliente());
            System.out.print(" " + c.getNombre());
            System.out.println(" " + c.getPaterno());
            String nombre_completo = c.getNombre() + " " + c.getPaterno() + " " + c.getMaterno();
            HashMap map = new HashMap();
            map.put("id", c.getIdcliente());
            map.put("label", nombre_completo);
            map.put("value", nombre_completo);
            lstClientes.add(map);
        }
        return lstClientes;
    }

    public Cliente getById(int idcliente) throws Exception {

        Cliente cliente = DAOFactory.getInst().getClienteDAO().getById(idcliente);
        return cliente;
    }
}
